﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Reflection;
using System.Web.UI;

namespace DD.NHibernateProvider
{
    public class NHibernateLinqDataSource : LinqDataSource
    {
        public NHibernateLinqDataSource()
        {
            FieldInfo fi = typeof(LinqDataSource).GetField("_view", BindingFlags.Instance | BindingFlags.NonPublic);
            var view = new NHibernateLinqDataSourceView(this, this.Context);
            fi.SetValue(this, view);
            if ((view != null) && base.IsTrackingViewState)
            {
                ((IStateManager)view).TrackViewState();
            }
        }
    }
}
